﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Catalog.CatalogItems;

namespace Catalog.CatalogTypes
{
    public class GameCatalog : Catalog
    {
        static GameCatalog()
        {
            AvailableGames = new HashSet<Game>();
        }

        private GameCatalog()
        {
        }

        public static HashSet<Game> AvailableGames { get; private set; }

        public static void AddNewItem(Game game)
        {
            AvailableGames.Add(game);

            Catalog.AddNewItem(game);
        }

        public static void RemoveItem(Game game)
        {
            AvailableGames.Remove(game);

            Catalog.RemoveItem(game);
        }

        public static string ShowAllFilms()
        {
            return GameCatalog.ToString();
        }

        static new string ToString()
        {
            StringBuilder result = new StringBuilder();

            if (AvailableGames.Count > 0)
            {
                result.AppendLine("All games: ");

                foreach (var item in AvailableGames)
                {
                    result.AppendLine(string.Format("    {0}", item.ToString()));
                }
            }

            return result.ToString();
        }
    }
}